<?php
$friends = $this->friends;
$info = $this->info;
$user_id = $this->user_id;
$auth = $this->auth;
$is_friend = $this->is_friend;
$message_new = $this->message_new;
 ?>
<!-- alert -->
<div class="class=sortable row-fluid ui-sortable" id="">
<div class="box-content alerts">
    <div class="alert alert-success" id="alert">

    </div>
</div>
</div>
<!-- alert -->
<!--message -->
<div class="sortable row-fluid ui-sortable">

    <a data-rel="tooltip" class="well span3 top-block" href="<?php echo $this->url('admin/child',array('controller'=>'user','action'=>'loademail', 'id'=>$auth->userid)) ?>" data-original-title="<?php echo $message_new->getCurrentItemCount(); ?> new messages.">
        <span class="icon32 icon-color icon-envelope-closed"></span>
        <div>You Have Messages</div>
        <div><?php echo $message_new->getCurrentItemCount(); ?></div>
        <span class="notification red"><?php echo $message_new->getCurrentItemCount(); ?></span>
    </a>

    <a data-rel="tooltip" class="well span3 top-block" href="#" data-original-title="6 new members.">
        <span class="icon32 icon-red icon-user"></span>
        <div>Total Members</div>
        <div>507</div>
        <span class="notification">6</span>
    </a>

    <a data-rel="tooltip" class="well span3 top-block" href="#" data-original-title="4 new pro members.">
        <span class="icon32 icon-color icon-star-on"></span>
        <div>Pro Members</div>
        <div>228</div>
        <span class="notification green">4</span>
    </a>

    <a data-rel="tooltip" class="well span3 top-block" href="#" data-original-title="$34 new sales.">
        <span class="icon32 icon-color icon-cart"></span>
        <div>Sales</div>
        <div>$13320</div>
        <span class="notification yellow">$34</span>
    </a>


</div>
<!--end message -->
<div class="row-fluid sortable ui-sortable">
    <!-- start user Profile-->
    <div class="box span8">
        <div class="box-header well">
            <h2><i class="icon-th"></i> User Profile</h2>
            <div class="box-icon">
                <a href="#" class="btn btn-setting btn-round"><i class="icon-cog"></i></a>
                <a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
                <a href="#" class="btn btn-close btn-round"><i class="icon-remove"></i></a>
            </div>
        </div>
        <div class="box-content">
            <!--avatar  -->
            <div class="box span5">
                <img src="<?php echo $info->avatar;  ?>">
            </div>
            <!-- end avatar -->

            <!--info  -->
            <div class="box span7">

                <div class="box-content">
                    <legend>User Detail: <?php echo $info->name; ?></legend>
                    <div class="control-group">
                        <label class="control-label">User Name: </label>
                        <div class="controls">
                            <input type="text" class="span12 typeahead" value="<?php echo $info->name; ?>" disabled >
                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label">Email: </label>
                        <div class="controls">
                            <input type="text" class="span12 typeahead" value="<?php echo $info->email; ?>" disabled >
                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label">Phone: </label>
                        <div class="controls">
                            <input type="text" class="span12 typeahead" value="<?php echo $info->phone; ?>" disabled >
                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label">Address: </label>
                        <div class="controls">
                            <input type="text" class="span12 typeahead" value="<?php echo $info->address; ?>" disabled >
                        </div>
                    </div>

                    <div class="controls">


                        <div class="btn-group ">
                            <button class="btn btn-large">Select Your Action</button>
                            <button class="btn btn-large dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>
                            <ul class="dropdown-menu">
                                <li><a href="<?php echo $this->url('admin/child',array('controller'=>'user','action'=>'edit','id'=>$info->id)) ?>"><i class="icon-star"></i>Edit Profile</a></li>
                                <?php if($auth->userid != $info->id && $is_friend!=1){ ?>
                                <li><a href="#" id="btn_addFriend"><i class="icon-tag"></i> Add Friend</a></li>
                                <li><a href="#" id="btn_followFriend"><i class="icon-download-alt"></i> Follow</a></li>
                                <?php } ?>
                                <li class="divider"></li>
                                <li><a href="#"><i class="icon-tint"></i> Separated link</a></li>
                            </ul>
                        </div>

                    </div>

                    <div class="control-group">
                        <label class="control-label"> </label>

                    </div>
                </div>
            </div>
            <!-- end info -->
        </div>
    </div><!--/span-->
    <!-- End user Profile-->

    <!--start Friend List -->
    <div class="box span4">
        <div class="box-header well" data-original-title="">
            <h2><i class="icon-user"></i> Friend List</h2>
            <div class="box-icon">
                <a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
                <a href="#" class="btn btn-close btn-round"><i class="icon-remove"></i></a>
            </div>
        </div>
        <div class="box-content" style="display: block;">
            <div class="box-content">
                <div class="row-fluid">
                <ul class="dashboard-list">
                    <?php
                        foreach($friends as $f){
                            $arr_class = \Velacolib\Utility\Utility::Friend_list_class($f->follow);
                    ?>
                            <li>
                                <a href="<?php echo $this->url('admin/child',array('controller'=>'user','action'=>'detail','id'=>$f->friend_id)) ?>">
                                    <img class="dashboard-avatar" alt="Usman" src="<?php echo $f->avatar; ?>"></a>
                                <strong>Name:</strong> <a href="<?php echo $this->url('admin/child',array('controller'=>'user','action'=>'detail','id'=>$f->friend_id)) ?>"><?php echo $f->name; ?>
                                </a><br>

                                <strong>Action:</strong> Delete<br>
                                <strong>Status:</strong> <span class="<?php echo $arr_class['class'] ?>"><?php echo $arr_class['type'] ?></span>
                            </li>
                    <?php

                        }
                    ?>

                </ul>
                    </div>
                <div class="row-fluid">
                    <?php // add at the end of the file after the table
                    echo $this->paginationControl(
                    // the paginator object
                        $friends,
                        // the scrolling style; see http://zf2.readthedocs.org/en/release-2.1.4/modules/zend.paginator.usage.html#rendering-pages-with-view-scripts
                        'sliding',
                        // the partial to use to render the control
                        array('partial/paginator.phtml', 'User'),
                        // the route to link to when a user clicks a control link
                        array(
                            'route' => 'admin/child',
                            'child_route' => array('controller'=>'user','action'=>'detail','id'=>$user_id)
                        )
                    );
                    ?>
                </div>
            </div>
        </div>
    </div><!--/span-->
    <!--- end friend List -->
</div>
<script>
    $(document).ready(function(){
       $('#alert').hide();
       $('#btn_addFriend').click(function(){
           AddFriend("0","friend");
           return false;
       });
        $('#btn_followFriend').click(function(){
            AddFriend("1","follow");
            return false;
        })

        function AddFriend(type, content_aler){
            var _form_user = "<?php echo $auth->userid; ?>";
            var _from_user_name = "<?php echo $auth->name; ?>";
            var _form_user_email = "<?php echo $auth->email; ?>";

            var _to_user_name = "<?php echo $info->name ?>";
            var _to_user_email = "<?php echo $info->email ?>";
            var _to_user = "<?php echo $info->id ?>";

            var _type_request = type;
            var _message_content = "You have 1 "+content_aler+" request from <?php echo $info->name; ?>";
            var _is_accepted = "0";

            $.ajax({
                type: "POST",
                url: "<?php echo $this->url('admin/child',array('controller'=>'user','action'=>'addfriend')) ?>",
                data: { form_user: _form_user,
                    from_user_name: _from_user_name,
                    form_user_email:_form_user_email,
                    to_user_name: _to_user_name,
                    to_user_email: _to_user_email,
                    to_user : _to_user,
                    type_request : _type_request,
                    message_content : _message_content,
                    is_accepted :_is_accepted
                }
            }).done(function(data){

                    if(data == 1)
                    {
                        var content = '<button type="button" class="close" data-dismiss="alert">×</button> <strong>Well Done</strong>  Your '+content_aler+' request has been sent.';
                        $('#alert').append(content);
                        $('#alert').show('slow');
                    }
                });
        }

    });
</script>